filechooserbutton: Clear model in destroy()
authorTimm Bäder <tbaeder@redhat.com>
Fri, 3 May 2019 06:10:50 +0000 (08:10 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 3 May 2019 18:06:23 +0000 (20:06 +0200)
Since we're destroying priv->chooser right after. We can't wait until
finalize() since clearing the model will try to work with priv->chooser.

gtk/gtkfilechooserbutton.c

index ea9de54450582db9c2e7191721aaee300a54dadb..ef4e000d905866001be14dd6b534689c452671d3 100644 (file)
@@ -994,12 +994,6 @@ gtk_file_chooser_button_finalize (GObject *object)
   if (priv->current_folder_while_inactive)
     g_object_unref (priv->current_folder_while_inactive);
 
-  if (priv->model)
-    {
-      model_remove_rows (button, 0, gtk_tree_model_iter_n_children (priv->model, NULL));
-      g_object_unref (priv->model);
-    }
-
   gtk_widget_unparent (priv->button);
   gtk_widget_unparent (priv->combo_box);
 
@@ -1032,6 +1026,12 @@ gtk_file_chooser_button_destroy (GtkWidget *widget)
   GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
   GSList *l;
 
+  if (priv->model)
+    {
+      model_remove_rows (button, 0, gtk_tree_model_iter_n_children (priv->model, NULL));
+      g_clear_object (&priv->model);
+    }
+
   if (priv->dialog != NULL)
     {
       gtk_widget_destroy (priv->dialog);